''' Mission 12 - Night Light Medium Solution - B The remix uses CodeX as an alarm. It detects when a light is turned on, changing the light intensity to at least room bright. This version also includes images for alarm set and alarm triggered. ''' from codex import * from time import sleep # select a value for breaking the darkness LIGHT_DETECT = 3000 # --- intro and set alarm display.print("CodeX Alarm") display.print() display.print("A = turn on") display.print("B = turn off") while True: if buttons.was_pressed(BTN_A): break # initialize count and set screen while True: value = light.read() # darkest value if value > LIGHT_DETECT: # turn on pixels, display target, increment count pixels.fill(RED, brightness=20) display.show(pics.SURPRISED) audio.pitch(500,0.3) sleep(0.1) audio.pitch(600, 0.3) sleep(0.1) else: pixels.fill(BLACK) display.show(pics.HOUSE) if buttons.was_pressed(BTN_B): break # ending display.clear() display.print("ALARM oFF")